/* send action to CoursesController with course id */
function processRequest(action, id) {
	$.ajax({
		type : "POST",
		url : $("#project-base").val()+'Courses',
		async : false,
		data : "action=" + action + "&id=" + id,
		success : function(msg) {
			window.location.href = $("#project-base").val()+"Courses/" + id;
		},
		error : function(msg) {
			switch (msg.status) {
			default:
				alert("You can't do this, perhaps the course is already full");
				window.location.reload();
				break;
			}
		}
	});
}

function deleteCourseByName(action, name) {
	$("body").addClass("darken");
	if (!confirm("Delete this course? (this cannot be undone)")) {
		$("body").removeClass("darken");
		return;
	}
	$("body").removeClass("darken");
	$.ajax({
		type : "POST",
		url : $("#project-base").val()+'Courses',
		async : false,
		data : "action=" + action + "&name=" + name,
		success : function(msg) {
			$("#course-error").html("");
			window.location.href = $("#project-base").val()+"Courses";
		},
		error : function(msg) {
			switch (msg.status) {
			default:
				alert("course coundn't be deleted");
				window.location.reload();
				break;
			}
		}
	});
}